home *** CD-ROM | disk | FTP | other *** search
Wrap
Oberon Document | 1994-06-07 | 9.1 KB | 226 lines | [ oODC/obnF]
Documents.StdDocumentDesc Documents.DocumentDesc Containers.ViewDesc Views.ViewDesc Stores.StoreDesc Documents.ModelDesc Containers.ModelDesc Models.ModelDesc Stores.ElemDesc TextViews.StdViewDesc TextViews.ViewDesc TextModels.StdModelDesc TextModels.ModelDesc TextModels.AttributesDesc Geneva TextRulers.StdRulerDesc TextRulers.RulerDesc TextRulers.StdStyleDesc TextRulers.StyleDesc TextRulers.AttributesDesc Geneva Geneva Geneva Geneva 7 The Forms Subsystem 7.1 FormModels DEFINITION FormModels; IMPORT Ports, Models, Views, Containers; CONST minView Size = 4 * Ports.point; maxViewSize = 160 * Ports.mm; TYPE Model = POINTER TO ModelDesc; ModelDesc = RECORD (Containers.ModelDesc) PROCEDURE (m: Model) Clone (): Model; PROCEDURE (m: Model) CopyFrom (source: Model); PROCEDURE (m: Model) Insert (v: Views.View; l, t, r, b: LONGINT); PROCEDURE (m: Model) Delete (v: Views.View); PROCEDURE (m: Model) Resize (v: Views.View; l, t, r, b: LONGINT); PROCEDURE (m: Model) PutAbove (v, p: Views.View); PROCEDURE (m: Model) Move (v: Views.View; dx, dy: LONGINT); PROCEDURE (m: Model) Copy (VAR v: Views.View; dx, dy: LONGINT); PROCEDURE (m: Model) NewReader (old: Reader): Reader; PROCEDURE (m: Model) NewWriter (old: Writer): Writer; PROCEDURE (m: Model) ViewAt (x, y: LONGINT): Views.View; PROCEDURE (m: Model) NofViews (): INTEGER END; Directory = POINTER TO DirectoryDesc; DirectoryDesc = RECORD PROCEDURE (d: Directory) New (): Model END; Context = POINTER TO ContextDesc; ContextDesc = RECORD (Models.ContextDesc) PROCEDURE (c: Context) ThisModel (): Model; PROCEDURE (c: Context) GetRect (VAR l, t, r, b: LONGINT) END; Reader = POINTER TO ReaderDesc; ReaderDesc = RECORD view: Views.View; l, t, r, b: LONGINT; PROCEDURE (r: Reader) Set (p: Views.View); PROCEDURE (r: Reader) ReadView (VAR v: Views.View) END; Writer = POINTER TO WriterDesc; WriterDesc = RECORD PROCEDURE (w: Writer) Set (p: Views.View); PROCEDURE (w: Writer) WriteView (v: Views.View; l, t, r, b: LONGINT) END; UpdateMsg = RECORD (Models.UpdateMsg) l, t, r, b: LONGINT END; VAR dir-, stdDir-: Directory; PROCEDURE GetRect (v: Views.View; VAR l, t, r, b: LONGINT); PROCEDURE SetDir (d: Directory); END FormModels. FormModels are container models which contain views. They have no further intrinsic contents. Form models can be used to arrange rectangular views in arbitrary layouts. Their main use is as data entry forms and as dialog layouts. CONST minViewSize This is the minimal width and height of a view which is embedded in a form model. CONST maxViewSize This is the maximal width and height of a view which is embedded in a form model. TYPE Model Interface, Extension Form models are container models (containers are not described here), which contain rectangular views and nothing else. PROCEDURE (m: Model) Clone (): Model Extension Result type is narrowed. PROCEDURE (m: Model) CopyFrom (source: Model) Copy contents of source to m. ~m.init 20 source # NIL 21 source.init 22 m.init PROCEDURE (m: Model) Insert (v: Views.View; l, t, r, b: LONGINT) Interface, Operation Insert view v with bounding box (l, t, r, b). v # NIL 20 v.init 21 v.context = NIL 22 l <= r 23 t <= b 24 v in m v.context # NIL & v.context.ThisModel() = m PROCEDURE (m: Model) Delete (v: Views.View) Interface, Operation Remove v from m. v in m 20 ~(v in m) PROCEDURE (m: Model) Resize (v: Views.View; l, t, r, b: LONGINT) Interface, Operation Redefine bounding box of v. v in m 20 l <= r 21 t <= b 22 PROCEDURE (m: Model) PutAbove (v, p: Views.View) Interface, Operation Change the vertical order of view v, such that it comes to lie directly above p if p # NIL, otherwise it is put to the bottom of the view list. v in m 20 p = NIL OR p in f 21 PROCEDURE (m: Model) Move (v: Views.View; dx, dy: LONGINT) Interface, Operation Move view v by (dx, dy), without changing its size. v in m 20 PROCEDURE (m: Model) Copy (VAR v: Views.View; dx, dy: LONGINT) Interface, Operation Create a copy of v and put it at v's bounding box shifted by (dx, dy). Parameter v returns the copy. v # NIL 20 v.context # NIL 21 v.context.ThisModel() = m 22 v # NIL & v # v' PROCEDURE (m: Model) ReplaceView (old, new: Views.View) Interface, Extension, Operation Retain the context of old, but replace old by new. old # NIL 20 new # NIL 21 old.context # NIL 22 new.context = NIL OR new.context = old.context 23 new.init 24 new.context = old.context PROCEDURE (m: Model) NewReader (old: Reader): Reader Returns a reader connected to f. An old reader may be passed as input parameter, if it isn't in use anymore. result # NIL PROCEDURE (m: Model) NewWriter (old: Writer): Writer Returns a writer connected to m. An old writer may be passed as input parameter, if it isn't in use anymore. result # NIL PROCEDURE (m: Model) ViewAt (x, y: LONGINT): Views.View Returns the topmost view in m which encloses position (x, y). result # NIL where (l, t, r, b) is the bounding box of v: (l <= x <= r) & (t <= y <= b) result = NIL no view at (x, y) PROCEDURE (m: Model) NofViews (): INTEGER Returns the number of views currently in m. result >= 0 TYPE Directory Interface Directory for the allocation of concrete form models. PROCEDURE (d: Directory) New (): Model Interface Create and return a new concrete form model. result # NIL result.init TYPE Context Extension, Interface Context of a view in a form. PROCEDURE (c: Context) ThisModel (): Model Extension, Interface Returns the form which contains the context. PROCEDURE (c: Context) GetRect (VAR l, t, r, b: LONGINT) Interface Returns the bounding box of the context's view. l < r & t < b TYPE Reader Interface Input rider on a form model. view: Views.View Most recently read view. l, t, r, b: LONGINT view # NIL => l < r & t < b Bounding box of most recently read view. PROCEDURE (r: Reader) Set (p: Views.View) Interface Set position of reader r to the view above p (i.e. the next view to be read will be the one directly above p) or to the bottom if p = NIL. p in Base(r) OR p = NIL 20 PROCEDURE (r: Reader) ReadView (VAR v: Views.View) Interface Reads the next view, in ascending order. If there is none, v is set to NIL. The reader's view and l, t, r, b fields will be set accordingly (l, t, r, b are undefined if view is NIL). v = r.view TYPE Writer Interface Output rider on a form. PROCEDURE (w: Writer) Set (p: Views.View) Interface Set position of writer w to the view above p (i.e. the next view to be written will be inserted directly above p) or to the bottom if p = NIL. p in Base(r) OR p = NIL 20 PROCEDURE (w: Writer) WriteView (v: Views.View; l, t, r, b: LONGINT) Interface Insert view v at the current position in w's form. v # NIL 20 v.init 21 v.context = NIL 22 l <= r 23 t <= b 24 v.init v.context # NIL TYPE UpdateMsg Extension This message indicates that a rectangular part of a form needs to be updated on the screen. The receiver must not switch on any marks as a reaction to having received this message. UpdateMsgs are sent by concrete form model implementations after any view modifications. UpdateMsgs are not extended. VAR dir-, stdDir-: Directory; dir # NIL & stdDir # NIL Form model directories. PROCEDURE GetRect (v: Views.View; VAR l, t, r, b: LONGINT) Returns the bounding box of view v, provided it is embedded in a form model. v # NIL 20 v.context # NIL 21 v.context IS Context 22 l < r & t < b PROCEDURE SetDir (d: Directory) Assign directory. d # NIL 20 dir = d TextControllers.StdCtrlDesc TextControllers.ControllerDesc Containers.ControllerDesc Controllers.ControllerDesc Geneva Documents.ControllerDesc